import { Component, OnInit, Input } from '@angular/core';
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd';
import { Output, EventEmitter } from '@angular/core';

import {Injectable} from '@angular/core'; 

@Component({
  selector: 'runtime',
  templateUrl: './runtime.component.html',
  styleUrls: ['./runtime.component.less']
})
export class RuntimeComponent implements OnInit {
  // @Output() newItemEvent = new EventEmitter<string>();
  list: any[] = [];
  disabled = false;
  rightbox = [];
  leftbox = [];

  runtimeList = [
    { key: 'python2.7', value: 'Python 2.7', code: false, icon: "#icon-runtimepython" },
    { key: 'python3.6', value: 'Python 3.6', code: false, icon: "#icon-runtimepython" },
    { key: 'nodejs10.22', value: 'Nodejs 10.22', code: false, icon: "#icon-runtimeNodejs" },
    { key: 'nodejs12.18', value: 'Nodejs 12.18', code: false, icon: "#icon-runtimeNodejs" },
    { key: 'golang1', value: 'Golang 1', code: false, icon: "#icon-runtimego" },
    { key: 'java8', value: 'Java 8', code: false, icon: "#icon-runtimejava" },
    { key: 'custom-container', value: '自定义镜像', code: false, icon: "#icon-runtimeDocker" },
  ]; // code为是否获取到了code

  select(ret: {}): void {
    // console.log('nzSelectChange', ret);
      this.leftbox.push(ret["list"]);
     
        if (ret["list"].length >= 5) {
         
         this.list.forEach(i => {
          if(i.checked != true){
            i['disabled'] = true;
           }
         })

          
        } 
        else {
          this.list.forEach(i => {
             i['disabled'] = false;
          })
        }
  }

 

  change(ret: {}): void {
    // console.log('nzChange', ret);
    // console.log(ret["list"])
    if(ret['to']==="right"){
      this.rightbox=ret["list"];
     
    }
		
    console.log(this.rightbox)
   
   
  }

  
    ngOnInit() {
        for (let i = 0; i < this.runtimeList.length; i++) {
          this.list.push({
            key: i.toString(),
            title: this.runtimeList[i].value,
						value: this.runtimeList[i].key,
            // disabled: i % 3 < 1,
          });
        }
       
      }
}